import 'package:flutter/material.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:mirror/main.dart';

class CommonLoading {
  static bool _isShow = false;

  static void show() {
    _isShow = true;
    showDialog(
        context: navigatorKey.currentContext!,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return Center(
            child: Container(
              padding: const EdgeInsets.all(50),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(16.0),
              ),
              child: LoadingAnimationWidget.discreteCircle(
                color: Colors.blue,
                size: 50,
              ),
            ),
          );
        });
  }

  static void hide() {
    if (!_isShow) return;

    _isShow = false;
    Navigator.pop(navigatorKey.currentContext!);
  }
}
